home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / eulisp / feel0_89.lha / Feel / AddOns / sstrm.em < prev    next >
Encoding:
Text File  |  1993-06-11  |  1.1 KB  |  51 lines

  1. ;; Eulisp Module
  2. ;; Author: pab
  3. ;; File: sstrm.em
  4. ;; Date: Fri Jun 11 01:23:50 1993
  5. ;;
  6. ;; Project:
  7. ;; Description: 
  8. ;;
  9.  
  10. (defmodule sstrm
  11.   (streams1
  12.    telos1
  13.    extras0
  14.    macros0
  15.    defs
  16.    error0 ;; debugging..
  17.    (except (flush close open print generic-prin prin format) init)
  18.    )
  19.   ()
  20.   
  21.   (setq stdout (open "/dev/tty" 'output t))
  22.  
  23.   (defstruct string-stream ()
  24.     ((content initform nil accessor string-stream-content)
  25.      (size initform 0 accessor string-stream-size))
  26.     constructor make-string-stream)
  27.  
  28.   (defmethod generic-output ((x string-stream) s)
  29.     (let ((s (if (stringp s) (copy s)
  30.            (convert s string))))
  31.       (format stdout "Out: '~a'~%" s)
  32.       ((setter string-stream-content) x
  33.        (cons s (string-stream-content x)))
  34.       ((setter string-stream-size) x 
  35.        (+ (string-stream-size x) (length s)))
  36.       s))
  37.   
  38.   ;; should be clever and use length field...
  39.   ;; unfortunately, I dont have string-subrange-copy.
  40.  
  41.   (defmethod (converter string) ((x string-stream))
  42.     (fold (lambda (sub str)
  43.         (string-append sub str))
  44.       (string-stream-content x)
  45.       ""))
  46.  
  47.         
  48.     
  49.   ;; end module
  50.   )
  51.